<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="test">
    <h2>显示格式化的日期时间</h2>
    <p>{{date}}</p>
    <p>完整版：{{date | dateString}}</p>
    <p>年月日：{{date | dateString('YYYY-MM-DD')}}</p>
    <p>时分秒：{{date | dateString('HH:mm:ss')}}</p>
</div>

<script type="text/javascript" src="../js/vue.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/moment.js/2.21.0/moment.js">
    //应用moment库，bootCDN
</script>
<script type="text/javascript">
    //自定义过滤器
    Vue.filter('dateString',function (value,format)  {
        return moment(value).format(format||'YYYY-MM-DD HH:mm:ss');
    })

    new Vue({
        el:'#test',
        data:{
            date: new Date()
        }
    })
</script>
</body>
</html>